Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Enable additional ccxt params and http headers #140

Merged
merged 28 commits into from
Apr 12, 2019

Conversation

Reidmcc
Copy link
Contributor

@Reidmcc Reidmcc commented Mar 31, 2019

This pr implements the feature requested in #139 by allowing users to specify any additional ccxt parameters and/or http headers they may need to add to their API requests. I have live tested it on Coinbase Pro, so if this is implemented we can marked Coinbase Pro as tested.

@Reidmcc Reidmcc requested a review from nikhilsaraf as a code owner March 31, 2019 17:19
Copy link
Contributor

@nikhilsaraf nikhilsaraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Reidmcc this is very useful, will try and merge it into master tomorrow. some comments inline.

api/exchange.go Outdated
@@ -14,6 +14,18 @@ type ExchangeAPIKey struct {
Secret string
}

// CcxtParam specifies an additional ccxt parameter
type CcxtParam struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Reidmcc mostly looks good. can you rename CcxtParam to ExchangeParam everywhere?
The exchange interface abstracts away the idea of ccxt / sdex / kraken from the calling code.

api/exchange.go Outdated
Value string
}

// ExchangeHeader specifies additional HTTP headers for centralized exchanges
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same logic as comment above, this comment should not say "centralized exchanges" since it abstracts away the concept of the underlying exchange.

cmd/trade.go Outdated
@@ -187,8 +187,24 @@ func makeExchangeShimSdex(
})
}

ccxtParams := []api.CcxtParam{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly, this here should be exchangeParams instead of ccxtParams

plugins/ccxtExchange.go Outdated Show resolved Hide resolved
@@ -14,6 +14,8 @@ import (

var supportedExchanges = []string{"binance"}
var emptyAPIKey = api.ExchangeAPIKey{}
var emptyParams = api.CcxtParam{}
var emptyHeader = api.ExchangeHeader{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Reidmcc there are a few tests here (ccxtExchange_test.go) that include the list of "tested" exchanges (example: TestGetOrderConstraints_Ccxt_Precision). Can you add coinbasepro to that test?

@Reidmcc
Copy link
Contributor Author

Reidmcc commented Apr 1, 2019

@nikhilsaraf changes made

@Reidmcc
Copy link
Contributor Author

Reidmcc commented Apr 1, 2019

ok, apparently I need to go over the ccxtExchange_test.go changes more carefully. I'll try to do that tonight.

Copy link
Contributor

@nikhilsaraf nikhilsaraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will wait for update.

exchangeName: "coinbasepro",
pair: &model.TradingPair{Base: model.XLM, Quote: model.USD},
wantPricePrecision: 6,
wantVolPrecision: 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you share the link where to find precision values for coinbasepro here? may be useful to put this as a comment inside each of these test cases
(don't worry about the kraken/binance cases, I'll add these links in)

@Reidmcc
Copy link
Contributor Author

Reidmcc commented Apr 2, 2019

@nikhilsaraf alright, it's fixed. It was failing because of the coinbase pro precision problems

@nikhilsaraf
Copy link
Contributor

@Reidmcc I've made some changes to merge the master branch in and fix some remaining comments and convention. I think this is pretty much good to go, could you test it out once? -- the precision override logic should also be included here so it should all just work.

Also, I could not find the coinbase pro API docs that show the headers and params that are needed. Do you have the link handy so I can add it in?

Copy link
Contributor

@nikhilsaraf nikhilsaraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Reidmcc Merging this in to master -- please test it and let me know if it's working for you as expected and we can mark the coinbasepro integration as tested, thanks!

@nikhilsaraf nikhilsaraf merged commit e7c76fe into stellar-deprecated:master Apr 12, 2019
@Reidmcc
Copy link
Contributor Author

Reidmcc commented Apr 13, 2019

@nikhilsaraf the parameters pass in fine, but the volume override isn't working correctly. Kelp still calculates volumes to SDEX precision, and when inverting for buy orders sometimes ends up with low over-precise values that can fail min volume tests if you set your volume to the minimum, i.e. if you set your volume to 1.0, Kelp may invert the volume to 0.99999981, and then reject the order at orderConstraintsFilter.

mtest_XLM_USD_20190413T134346CDT.log

@Reidmcc
Copy link
Contributor Author

Reidmcc commented Apr 13, 2019

@nikhilsaraf cbpro header reqs are here https://docs.pro.coinbase.com/#creating-a-request

@nikhilsaraf
Copy link
Contributor

@Reidmcc filed an issue for the incorrect volume amounts here: #155

For now I'd recommend using an AMOUNT_OF_A_BASE value that is slightly higher than the CENTRALIZED_MIN_BASE_VOLUME_OVERRIDE amount

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants